<?php use_helper('Form') ?>
<h1>Órgão Externo</h1>
<h2><?php echo $orgao_externo->getname() ?></h2>
<strong><?php echo $orgao_externo->getsg_orgao_externo() ?></strong> - <?php echo $orgao_externo->getno_longo() ?>

<p><?php echo button_to('Editar','orgao_externo/edit?cd_orgao_externo='.$orgao_externo->getCdOrgaoExterno(),'class="btn"') ?>
&nbsp;

<hr />
<table>
  <tbody>
    <?php foreach ($usr_vinculado_list as $i => $usr_vinculado): ?>
    <tr class="<?php echo fmod($i, 2) ? 'even' : 'odd' ?>">
      <td><?php echo $usr_vinculado->getUsuario()->getName() ?></td>
      <td><?php echo $usr_vinculado->getUsuario()->getNoEmail() ?></td>
      <td width="2%">
		<?php echo link_to(image_tag('desvincular_usuario.gif'
								     , 'title="desvincular usuário"')
						  ,'orgao_externo/desvincula?cd_usuario='.$usr_vinculado->getUsuario()->getCdUsuario()
						  ,array('confirm' => 'Confirma desvinculação de '.$usr_vinculado->getUsuario()->getName().' ao '.$orgao_externo->getname().'?')) ?>
	  </td>
    </tr>
    <?php endforeach; ?>
  </tbody>
</table>

<br>

<?php 
  $options = array();
  foreach ($usr_nao_vinculado_list as $usr) {
    $options[$usr->getCdUsuario()] = $usr->getName();
  }
  $this->options = $options;
?>
<?php if ($options) : ?>
  <form action="<?php echo url_for('orgao_externo/vincula') ?>" method="post">
  	<?php echo input_hidden_tag('cd_orgao_externo',$cd_orgao_externo) ?>

    <?php echo select_tag('cd_usuario', $options) ?>
    <input type="submit" value="Vincular" class="btn" />
  </form>
<?php else : ?>
  <center>
  	<p class="error_list"><?php echo image_tag('alert.gif', array('alt' => 'Alerta', 'title' => 'Alerta'))?> Sem usuários externos pendentes de vinculação!
	<?php echo link_to('(Cadastrar Usuários)','usuario/new') ?>
  </center>
<?php endif ?>

<p><a href="<?php echo url_for('orgao_externo/index') ?>">Voltar</a>

